from django.db import models
from django.contrib.auth.models import AbstractUser


# Create your models here.
# 用户注册 使用django自带的用户模型
class User(AbstractUser):
    # 增加一个手机号字段
    DoesNotExist = None
    phone = models.CharField(max_length=11, unique=True, verbose_name='手机号')
    # 用户中心，需要添加
    email_active = models.BooleanField(default=False, verbose_name='邮箱验证状态')

    class Meta:  # 配置数据库表名，以及设置模型在admin后台站点显示的中文名
        db_table = 'tb_users'
        verbose_name = '用户'
        verbose_name_plural = verbose_name

    """
mysql> desc tb_users;
+--------------+--------------+------+-----+---------+----------------+
| Field        | Type         | Null | Key | Default | Extra          |
+--------------+--------------+------+-----+---------+----------------+
| id           | bigint       | NO   | PRI | NULL    | auto_increment |
| password     | varchar(128) | NO   |     | NULL    |                |
| last_login   | datetime(6)  | YES  |     | NULL    |                |
| is_superuser | tinyint(1)   | NO   |     | NULL    |                |
| username     | varchar(150) | NO   | UNI | NULL    |                |
| first_name   | varchar(150) | NO   |     | NULL    |                |
| last_name    | varchar(150) | NO   |     | NULL    |                |
| email        | varchar(254) | NO   |     | NULL    |                |
| is_staff     | tinyint(1)   | NO   |     | NULL    |                |
| is_active    | tinyint(1)   | NO   |     | NULL    |                |
| date_joined  | datetime(6)  | NO   |     | NULL    |                |
| phone        | varchar(11)  | NO   | UNI | NULL    |                |
+--------------+--------------+------+-----+---------+----------------+
12 rows in set (0.02 sec)
    """
